@namespace RazorConsole.Components

@using System
@using System.Globalization
@using Microsoft.AspNetCore.Components
@using RazorConsole.Core.Rendering.ComponentMarkup

<div class="grid"
    data-columns="@ColumnAttribute"
    data-expand="@ExpandAttribute"
    data-width="@WidthAttribute">
    @ChildContent
</div>

@code {
    [Parameter]
    public RenderFragment? ChildContent { get; set; }

    [Parameter]
    public int Columns { get; set; } = 2;

    [Parameter]
    public bool Expand { get; set; }

    [Parameter]
    public int? Width { get; set; }

    private string ColumnAttribute => Columns.ToString(CultureInfo.InvariantCulture);

    private string ExpandAttribute => Expand ? "true" : "false";

    private string? WidthAttribute => Width.HasValue && Width.Value > 0
        ? Width.Value.ToString(CultureInfo.InvariantCulture)
        : null;
}
